<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCommissionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('commissions', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id')->index()->comment('用户ID');
            $table->bigInteger('child_user_id')->index()->comment('下级用户ID');
            $table->bigInteger('child_user_withdraw_id')->comment('下级用户提现ID');
            $table->decimal('child_user_money')->comment('下级累计提现金额');
            $table->decimal('user_money')->default(0)->comment('用户获得佣金');
            $table->integer('exchange_rate')->default(0)->comment('兑换比例');
            $table->bigInteger('amount')->default(0)->comment('兑换金币');
            $table->timestamp('child_user_withdraw_at')->comment('提现时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('commissions');
    }
}
